// $Id$
// Licensed under Apache License Version 2.0
// See: http://www.apache.org/licenses/LICENSE-2.0.html
package de.servicezombie.lang.text;

public class OrderByClause {

	public static enum Order {
		ASC, DESC;
	}

	private Order order;
	private String fieldName;

	public OrderByClause(Order order, String fieldName) {
		super();
		this.order = order;
		this.fieldName = fieldName;
	}

	public String getFieldName() {
		return fieldName;
	}

	public Order getOrder() {
		return order;
	}

	@Override
	public String toString() {
		return "OrderByClause [order=" + order + ", fieldName=" + fieldName + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((fieldName == null) ? 0 : fieldName.hashCode());
		result = prime * result + ((order == null) ? 0 : order.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		OrderByClause other = (OrderByClause) obj;
		if (fieldName == null) {
			if (other.fieldName != null)
				return false;
		}
		else if (!fieldName.equals(other.fieldName))
			return false;
		if (order != other.order)
			return false;
		return true;
	}

}
